// 导入组件
import Vue from 'vue';
import Router from 'vue-router';

const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(error => error)
}

const VueRouterReplace = Router.prototype.replace
Router.prototype.replace = function replace(to) {
    return VueRouterReplace.call(this, to).catch(err => err)
}

// 启用路由
Vue.use(Router);

// 导出路由 
export default new Router({
    mode: 'history',
    routes: [{
        path: '/',
        name: '',
        component: () =>
            import ('../views/login.vue'),
        hidden: true,
        meta: {
            requireAuth: false
        }
    }, {
        path: '/login',
        name: '登录',
        component: () =>
            import ('../views/login.vue'),
        hidden: true,
        meta: {
            requireAuth: false
        }
    }, {
        path: '/index',
        name: '首页',
        component: () =>
            import ('../views/index.vue'),
        iconCls: 'el-icon-tickets',
        children: [{
                path: '/varity/varity',
                name: 'Varity',
                component: () =>
                    import ('../views/varity/varity.vue'),
                meta: {
                    requireAuth: true
                }
            },
            {
                path: '/user',
                name: 'User',
                component: () =>
                    import ('../views/user/index.vue'),
                meta: {
                    requireAuth: true
                }
            },
            {
                path: '/order',
                name: 'Order',
                component: () =>
                    import ('../views/order/index.vue'),
                meta: {
                    requireAuth: true
                }
            },
            {
                path: '/comment',
                name: 'Comment',
                component: () =>
                    import ('../views/comment/index.vue'),
                meta: {
                    requireAuth: true
                }
            },
            {
                path: '/goods/recommend',
                name: 'Recommend',
                component: () =>
                    import ('../views/goods/recommend.vue'),
                meta: {
                    requireAuth: true
                }
            },
            {
                path: '/goods/sellGoods',
                name: 'SellGoods',
                component: () =>
                    import ('../views/goods/sellGoods.vue'),
                meta: {
                    requireAuth: true
                }
            },
            {
                path: '/charts/sell',
                name: 'Sell',
                component: () =>
                    import ('../views/charts/sell.vue'),
                meta: {
                    requireAuth: true
                }
            },
            {
                path: '/daity/daity',
                name: 'DaityDaity',
                component: () =>
                    import ('../views/daity/daity.vue'),
                meta: {
                    requireAuth: true
                }
            },
            {
                path: '/daity/comment',
                name: 'DaityComment',
                component: () =>
                    import ('../views/daity/comment.vue'),
                meta: {
                    requireAuth: true
                }
            }
        ]
    }]
})